package com.byedu.course.controller;

import com.byedu.course.UserCourseService;
import com.byedu.domain.course.CourseCount;
import com.byedu.domain.course.vo.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Controller
@RequestMapping("/usercourse")
public class UserCourseController {

    @Autowired
    private UserCourseService userCourseService;

    @ResponseBody
    @RequestMapping(value = "/addUserCourse", method = {RequestMethod.POST})
    public Integer getUserQuestionsByUserId(@RequestBody UserCourseVO userCourseVO) {

        return userCourseService.addUserCourse(userCourseVO);
    }
    @ResponseBody
    @RequestMapping(value = "/test", method = {RequestMethod.GET})
    public List<CourseCount> listCourseMap() {

        return userCourseService.getcidcount();
    }
    /**
     * @return
     * @description 判断课程是否已经购买了
     */
    @ResponseBody
    @RequestMapping(value = "/{userId}/{courseId}", method = {RequestMethod.GET})
    public boolean getbayCourse(@PathVariable String userId, @PathVariable String courseId) {


        return userCourseService.getbayCourse(userId, courseId);
    }
}
